<?php //Begin widget code
//** ADMINISTRATION FILES **//
 	// Theme variables
	require_once (TEMPLATEPATH . '/library/functions/theme_variables.php');
    // Theme admin functions
    require_once ($functions_path . 'admin_functions.php');
    // Theme admin options
    require_once ($functions_path . 'admin_options.php');
    // Theme admin Settings
    require_once ($functions_path . 'admin_settings.php');
	// Comments
    require_once ($functions_path . 'comments_functions.php');
// Widgetss
    require_once ($functions_path . 'widgets_functions.php');
	require(TEMPLATEPATH . "/product_menu.php");
 	//require_once ($functions_path . 'yoast-canonical.php');
	require_once ($functions_path . 'yoast-breadcrumbs.php');
	require_once ($functions_path . 'general_functions.php');
	require_once (TEMPLATEPATH . '/language.php');
	require_once (TEMPLATEPATH . '/library/functions/admin_dashboard.php');
	require_once (TEMPLATEPATH . '/library/functions/custom_functions.php');
	
	
	if('themes.php' == basename($_SERVER['SCRIPT_FILENAME'])) 
	{
		if($_REQUEST['dummy']=='del')
		{
			delete_dummy_data();	
			echo THEME_DUMMY_DELETE_MESSAGE;
		}
		if(($_REQUEST['template']=='' && $post_counts>0 && $_REQUEST['page']=='') || $_REQUEST['activated']=='true')
		{
			echo THEME_ACTIVE_MESSAGE;
		}
		if($_REQUEST['activated'])
		{
			require_once (TEMPLATEPATH . '/auto_install.php');
		}
	}
	
	function delete_dummy_data()
	{
		global $wpdb;
		$productArray = array();
		$pids_sql = "select p.ID from $wpdb->posts p join $wpdb->postmeta pm on pm.post_id=p.ID where meta_key='pt_dummy_content' and meta_value=1";
		$pids_info = $wpdb->get_results($pids_sql);
		foreach($pids_info as $pids_info_obj)
		{
			$productArray[] = $pids_info_obj->ID; 
		}
		if($productArray)
		{
			$product_ids = implode(',',$productArray);
			$commentsql = "delete from $wpdb->comments where comment_post_ID in ($product_ids)";
			$wpdb->query($commentsql);
			$postmetasql = "delete from $wpdb->postmeta where post_id in ($product_ids)";
			$wpdb->query($postmetasql);
			$postmetasql = "delete from $wpdb->term_relationships where object_id in ($product_ids)";
			$wpdb->query($postmetasql);
			$postmetasql = "delete from $wpdb->posts where ID in ($product_ids)";
			$wpdb->query($postmetasql);
		}
	}

?>